package goleetcode

func satisfiesConditions(grid [][]int) bool {
	n := len(grid)
	m := len(grid[0])
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			g := grid[i][j]
			if (i + 1 < n && grid[i + 1][j] != g) {
				return false
			}
			if (j + 1 <m && grid[i][j + 1] == g) {
				return false
			}
		}
	}
	return true
}